<?php

class Employee extends AppModel {

    var $name = 'Employee';
    var $validate = array(
        'first_name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'last_name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'deleted' => array(
            'numeric' => array(
                'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );
    //The Associations below have been created with all possible keys, those that are not needed can be removed
    /*
      var $hasAndBelongsToMany = array(
      'Event' => array(
      'className' => 'Event',
      'joinTable' => 'events_employees',
      'foreignKey' => 'employee_id',
      'associationForeignKey' => 'event_id',
      'unique' => true,
      'conditions' => '',
      'fields' => '',
      'order' => '',
      'limit' => '',
      'offset' => '',
      'finderQuery' => '',
      'deleteQuery' => '',
      'insertQuery' => ''
      ),
      'JobsDetail' => array(
      'className' => 'JobsDetail',
      'joinTable' => 'jobs_details_employees',
      'foreignKey' => 'employee_id',
      'associationForeignKey' => 'jobs_detail_id',
      'unique' => true,
      'conditions' => '',
      'fields' => '',
      'order' => '',
      'limit' => '',
      'offset' => '',
      'finderQuery' => '',
      'deleteQuery' => '',
      'insertQuery' => ''
      )
      );
     */

    /**
     * Función que me devuelve todos nombres de los empleados indexado por id
     */
    function getListName() {
        $array_empleados = $this->find('all', array('recursive' => -1));
        $employees = array();
        foreach ($array_empleados as $employee) {
            $employees[$employee['Employee']['id']] = $employee['Employee']['first_name'] . ' ' . $employee['Employee']['last_name'];
        }
        
        return $employees;
    }

}
